import {postRequest} from "@/utils/api";
import {Message} from 'element-ui'
import router from '@/router'

const state = {
    routes: []
}
const mutations = {
    INIT_ROUTES(state, data) {
        state.routes = data;
    },
    LOGOUT(state){
        state.routes = [];
        sessionStorage.removeItem('userInfo')
        localStorage.removeItem('tokenStr')
        // Message.success({message: "注销成功！"})
        router.replace('/');
    }
}
const actions = {
    async logout({commit},userInfo){
        await postRequest("/logout",userInfo)
        commit('LOGOUT')
    }
}
const getters = {}

export default {
    namespaced: true,
    state, mutations, actions, getters
}
